package com.hulk.utils;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class BeanFactory implements ApplicationContextAware {

	private static ApplicationContext internalApplicationContext = null;

	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		internalApplicationContext = applicationContext;
	}

	public static Object getBean(String beanName) throws Exception {
		try {
			return internalApplicationContext.getBean(beanName);
		} catch (BeansException ex) {
			throw new Exception(ex);
		} catch (Exception ex) {
			throw new Exception(ex);
		}
	}

	public static boolean containsBean(String beanName) throws Exception {
		try {
			return internalApplicationContext.containsBean(beanName);
		} catch (BeansException ex) {
			throw new Exception(ex);
		} catch (Exception ex) {
			throw new Exception(ex);
		}
	}

}
